package com.ciban.smarthome.module.ui.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ciban.smarthome.R;
import com.ciban.smarthome.module.entity.Equip_Projector;

public class ProjectorListAdapter extends BaseAdapter {

	private ArrayList<Equip_Projector> list;
	private Context context;

	public ProjectorListAdapter(Context context, ArrayList<Equip_Projector> list) {
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = View.inflate(context,
					R.layout.listitem_projector_select, null);
			holder = new ViewHolder();
			holder.tv_name = (TextView) convertView
					.findViewById(R.id.projector_pop_name);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		Equip_Projector info = list.get(position);
		holder.tv_name.setText(info.getName());

		return convertView;
	}

	static class ViewHolder {
		TextView tv_name;
	}

}
